{% extends 'layout.html' %}
{% load static %}
{% load permission %}
{% block content %}
{#<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">#}
{#  Launch demo modal#}
{#</button>#}
<div style="margin-bottom: 5px" class="clearfix">
{#    <a href="{% url 'customer_add' %}" class="btn btn-success"><span class="glyphicon glyphicon-plus-sign"></span>#}
{#        新建</a>#}
    {% add_permission request 'customer_add' %}
<form class="form-inline right" method="get">
  <div class="form-group">
    <label class="sr-only" for="exampleInputEmail3">Email address</label>
    <input type="text" name="keyword" class="form-control" id="exampleInputEmail3" placeholder="请输入需要查找的内容" value="{{ keyword }}">
  </div>
  <button type="submit" class="btn btn-default glyphicon glyphicon-search"></button>
</form>

</div>
    <table class="table table-bordered">
        <thead>
        <tr>
            <th>ID</th>
            <th>名字</th>
            <th>手机号码</th>
            <th>余额</th>
            <th>会员级别</th>
            <th>创建时间</th>
            <th>重置密码</th>
            <th>订单详情</th>
            {% if request|has_permission:"customer_edit,customer_delete" %}
            <th>操作</th>
            {% endif %}
        </tr>
        </thead>
        <tbody>
        {% for row in pager.queryset %}
            <tr row-id="{{ row.id }}">
                <td>{{ row.id }}</td>
                <td>{{ row.name }}</td>
                <td>{{ row.mobile }}</td>
                <td>{{ row.balance }}</td>
                <td>{{ row.leval.title }}</td>
                <td>{{ row.create_time|date:"Y-m-d" }}</td>
                <td><a href="{% url "customer_reset" pk=row.id %}">密码重置</a></td>
                <td><a href="{% url "customer_charge" pk=row.id %}">订单详情</a></td>
                {% if request|has_permission:"customer_edit,customer_delete" %}
                <td>
{#                    <a href="{% url 'customer_edit' pk=row.id %}" class="btn btn-primary btn-xs">编辑</a>#}
{#                    <a href="{% url 'customer_delete'%}" class="btn btn-danger btn-xs btn-lg btn_delete" cid="{{ row.id }}"  data-toggle="modal" data-target="#myModal">删除</a>#}
                {% edit_permission request 'customer_edit' pk=row.id %}
                {% delete_permission request 'customer_delete' pk=row.id %}
                </td>
            {% endif %}
            </tr>
        {% endfor %}

        </tbody>
    </table>
{% include 'include/deleteModel.html' %}
<nav aria-label="Page navigation">
  <ul class="pagination">
    {{ pager.html }}
  </ul>
</nav>

{% endblock %}

{% block js %}
    <script src="{% static '/js/delete_model.js' %}"></script>
    <script>
    var DELETE_CID;
    var DELETE_URL = "{% url 'customer_delete' %}";
    </script>
{% endblock %}

